<?php

class Template {
	
	const PAGE = 'page';
	const SEARCH = 'search';
	
	public $name;
	public $path;
	
	public $request_type;
	public $menu_pages;
	
	public $page;	
	public $search_query;
	public $search_results;
	
	public function __construct($name, $path) {
		$this->name = $name;
		$this->path = $path;
	}
	
	// Returns the relative path from the systems root to the given filename
	public function getStaticPath($filename) {
		return $this->path . '/' . $filename;
	}
	
	// Short for getStaticPath
	public function getPath($filename) {
		return $this->getStaticPath($filename);
	}
	
	public function getIndexPath() {
		return $this->path . '/index.php';
	}
	
	public function isPage() {
		return $this->request_type == Template::PAGE;
	}
	
	public function isSearch() {
		return $this->request_type == Template::SEARCH;
	}
	
	public function isPageFound() {
		return $this->page != null;
	}
	
	public function getPageData() {
		return $this->page;
	}
	
	public function getTitle() {
		return $this->page['title'];
	}
	
	public function getAuthor() {
		return $this->page['first_name'] . ' ' . $this->page['last_name'];
	}
	
	public function getText() {
		return $this->page['text'];
	}
	
	public function getTimestamp() {
		return $this->page['updated_at'];
	}	
	
	public function getQuery() {
		return $this->search_query;
	}
	
	public function getResults() {
		return $this->search_results;
	}

	public function getMenu() {
		return $this->menu_pages;
	}
}

?>